package fractal;

import jinyilw.swing.FontTools;
import jinyilw.swing.WindowTools;
import jinyilw.swing.i18n.ICSetting;
import jinyilw.swing.visuals.Icomp.ILabel;
import jinyilw.swing.visuals.Icomp.IRichLabel;
import jinyilw.swing.visuals.Jwindow.TransWindow;

import javax.swing.SwingConstants;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class HelpWindow extends TransWindow
{
	private static final long serialVersionUID = 558103229895911238L;
	private final Font textFont = new Font("", Font.BOLD, 12);
	private final ILabel[] labels = new ILabel[20];

	public HelpWindow()
	{
		super();
		initGUI();
	}

	private void initGUI()
	{
		setSize(410, 560);
		setBGOpacity(150);
		setMovable(true);
		setAlwaysOnTop(true);
		Container cPanel = getContentPane();
		cPanel.addMouseListener(new ThisContentPaneMouseListener());
		cPanel.setLayout(null);

		labels[0] = new IRichLabel();
		labels[1] = new IRichLabel();
		for (int i = 2; i < labels.length; i++)
		{
			labels[i] = new ILabel();
			labels[i].setFont(textFont);
		}
		for (ILabel iLabel : labels)
		{
			cPanel.add(iLabel);
			iLabel.setSize(410, 20);
			iLabel.setHorizontalAlignment(SwingConstants.CENTER);
		}
		labels[0].setLocation(0, 10);
		int y = 40;
		for (int i = 2; i <= 10; i++)
		{
			labels[i].setLocation(0, y);
			y += 25;
		}
		y += 20;
		labels[1].setLocation(0, y);
		y += 30;
		for (int i = 11; i < labels.length; i++)
		{
			labels[i].setLocation(0, y);
			y += 25;
		}

		labels[0].setFont(FontTools.getCustomFont(14));
		labels[0].setText(new ICSetting("controlHelps", "控制面板帮助信息",
				"Control panels helps"));
		labels[0].setForeground(Color.CYAN);
		labels[2].setText(
				new ICSetting("helpInfo1", "☆ 应用调色板功能，可以添加、更改、清除颜色 ☆",
						"☆ Use the palette to add, change, and clear colors ☆"),
				true);
		labels[3].setText(new ICSetting("helpInfo2",
						"☆ 选择颜色后，左键在图像上单击添加或更改颜色 ☆",
						"☆ After select a color, left-click to add or change image color ☆"),
				true);
		labels[4].setText(new ICSetting("helpInfo3", "☆ 右键单击相应区域可以清除及复原图像颜色 ☆",
						"☆ Right-click a specific area to clear and restore image color ☆"),
				true);
		labels[5].setText(new ICSetting("helpInfo4",
						"☆ 保存图片可以选择 png、jpg、bmp 三种格式 ☆",
						"☆ You can save pictures in three formats: png, jpg, and bmp ☆"),
				true);
		labels[6].setText(new ICSetting("helpInfo5",
						"☆ 保存为png格式的图片质量较好，建议选择png ☆",
						"☆ Png format picture is better, it is recommended to choose png☆"),
				true);
		labels[7].setText(new ICSetting("helpInfo6",
				"☆ 可将当前的分形图像设置为初始界面，再次打开时完整复原 ☆",
				"☆Set current to be initial interface and fully restored when open again☆",
				labels[7], 2));
		labels[8].setText(new ICSetting("helpInfo7",
						"☆ 可将分形图像参数保存为较小的 fra文件，记录完整分形参数 ☆",
						"☆ You can save the full fractal parameters as a smaller fra file ☆"),
				true);
		labels[9].setText(new ICSetting("helpInfo8",
						"☆ fra文件可从网上获取或上传，实现更多精美分形的分享 ☆",
						"☆ Fra files can be obtained from or uploaded to the Internet ☆"),
				true);
		labels[10].setText(new ICSetting("helpInfo9",
						"☆ 可将定义的分形动画参数保存为 ani文件 ☆",
						"☆ You can save fractal animation parameters as ani files ☆"),
				true);

		labels[1].setFont(FontTools.getCustomFont(14));
		labels[1].setText(new ICSetting("expandHelps", "展开放大面板帮助信息",
				"Expand panel helps"));
		labels[1].setForeground(Color.CYAN);
		labels[11].setText(new ICSetting("helpInfo10", "☆  调整窗口大小：拖动四周边框  ☆",
				"☆  Resize window：Drag the borders  ☆"));
		labels[12].setText(new ICSetting("helpInfo11",
						"☆ 放大：左键向右拖动 ☆                      ☆ 移动：右键拖动 ☆",
						"☆ Zoom in: Drag leftbutton to right ☆   ☆ Move: Drag rightbutton ☆"),
				true);
		labels[13].setText(new ICSetting("helpInfo12",
				"☆ 后退：左键向左拖动、“<” ☆     ☆ 前进：右键单击、“>” ☆ ",
				"☆ Backward：Drag leftbutton to left、“<” ☆  Forward: Right-click、“>” ☆ ",
				labels[13], 2));
		labels[14].setText(new ICSetting("helpInfo13",
				"☆ 上移：“↑” ☆ 下移：“↓”   ☆ 左移：“←” ☆ 右移：“→” ☆",
				"☆ Move up：“↑” ☆ Move down：“↓”   ☆ Move left：“←” ☆ Move right：“→” ☆",
				labels[14], 3));
		labels[15].setText(new ICSetting("helpInfo14",
				"☆ 连续上移：“W” ☆                              ☆ 连续下移：“S” ☆ ",
				"☆ Continuous move up：“W” ☆            ☆ Continuous move down：“S” ☆ ",
				labels[15], 2));
		labels[16].setText(new ICSetting("helpInfo15",
				"☆ 连续左移：“A” ☆                              ☆ 连续右移：“D” ☆",
				"☆ Continuous move left：“A” ☆            ☆ Continuous move right：“D” ☆ ",
				labels[16], 2));
		labels[17].setText(new ICSetting("helpInfo16",
				"☆ 分形生长：“F1” ☆                             ☆ 分形消除：“F2” ☆",
				"☆ Fractal grow：“F1” ☆         ☆ Fractal Shrink：“F2” ☆ ",
				labels[17], 1));
		labels[18].setText(new ICSetting("helpInfo17",
				"☆ 连续放大：长按左键、“F3” ☆ 连续缩小：长按右键、“F4” ☆",
				"☆ Continuous in: hold left-button、“F3” ☆ Continuous out: hold right-button、“F4”"
						+ " ☆",
				labels[18], 3));
		labels[19].setText(new ICSetting("helpInfo18",
				"☆  停止动画：左键单击、空格键  ☆  关闭：ESC键  ☆",
				"☆  Stop animation：left-click、space bar  ☆  Close：“ESC”  ☆"));
	}

	private class ThisContentPaneMouseListener extends MouseAdapter
	{
		@Override
		public void mouseClicked(MouseEvent e)
		{
			WindowTools.hideWindowToRight(HelpWindow.this);
		}
	}
}
